<?php 
namespace app\store\model\lottery;

use app\common\library\helper;
use app\common\model\lottery\ActivePrize as ActivePrizeModel;
use app\store\model\lottery\Prize as PrizeModel;
/**
 * 
 */
class ActivePrize extends ActivePrizeModel
{
	/**
     * 获取奖品模型
     * @return Goods
     */
    protected function getPrizeModel()
    {
        return new PrizeModel;
    }

    /**
     * 同步删除活动会场与奖品关联记录
     */
    public function onDeleteLotteryPrize($lotteryPrizeId)
    {
        $this->where('prize_id', '=', $lotteryPrizeId)->delete();
    }

     /**
     * 活动ID获取商品列表
     */
    public static function getPrizeListByActiveId($active_id)
    {
        $model = new static;
        $activePrizeList = $model->getLotteryPrizeByActiveId($active_id);
        $activePrizeIdList = helper::arrayColumn2Key($activePrizeList, 'prize_id');
        $activeids = array_keys($activePrizeIdList);
        return  $model->getGoodsListByIds($activeids,[]);
    }

    /**
     * 根据活动ID集查询奖品列表
     */
    private function getGoodsListByIds($lotteryPrizeIds, $param = [])
    {
        return $this->getPrizeModel()->getListByIds($lotteryPrizeIds, $param);
    }

    // 活动商品
    private function getLotteryPrizeByActiveId($active_id)
    {
        return $this->where('active_id', '=', $active_id)->select();
    }





}

?>